#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
const int N=110;

int T;
int n;
int a[N],c[N];
int b[N];
int powe[N];
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    powe[0]=1;
    for(int i=1;i<=20;i++){
        powe[i]=2*powe[i-1];
    }
    cin>>T;
    while(T--){
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        //0 red 1 blue

        int mx=0;
        for(int k=0;k<powe[n];k++){
            int zt=k;
            for(int i=1;i<=n;i++){
                b[i]=zt%2;
                zt=zt>>1;
            }
            memset(c,0,sizeof c);
            for(int i=1;i<=n;i++){
                int ps=0;
                for(int j=i-1;j>=1;j--){
                    if(b[i]==b[j]){
                        ps=j;break;
                    }
                }
                if(ps==0) c[i]=0;
                if(ps!=0&&a[i]==a[ps]) c[i]=a[i];
                if(ps!=0&&a[i]!=a[ps]) c[i]=0;
            }
            int ans=0;
            for(int i=1;i<=n;i++) ans+=c[i];
            mx=max(mx,ans);
        }
        cout<<mx<<endl;
    }
    return 0;
}
/*
3
3
1 2 1
4
1 2 3 4
8
3 5 2 5 1 2 1 4
*/
/*
2
15
5 3 7 2 4 13 11 6 5 5 3 5 12 8 13
15
1 12 11 11 7 11 15 6 4 6 3 15 7 5 2
*/
/*
18
37
*/
